package com.bbm.bbmanage.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bbm.bbmanage.entity.HouseStar;
import com.bbm.bbmanage.entity.vo.ResponseResult;
import com.bbm.bbmanage.service.HouseStarService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * (HouseStar)表控制层
 *
 * @author lionkliu
 * @since 2024-03-24 14:33:55
 */
@RestController
@RequestMapping("houseStar")
public class HouseStarController {

    @Resource
    private HouseStarService houseStarService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return houseStarService.selectPage(pageNum, pageSize);
    }

    @GetMapping("/check")
    public ResponseResult isStar(@RequestParam("userId") Integer userId,
                                 @RequestParam("houseId") Long houseId) {
        return houseStarService.isStar(userId, houseId);
    }

    @GetMapping("{userId}")
    public ResponseResult getStarUserId(@PathVariable Long userId) {
        return houseStarService.getStarUserId(userId);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody HouseStar houseStar) {
        return houseStarService.insertOne(houseStar);
    }

    @PutMapping
    public ResponseResult update(@RequestBody HouseStar houseStar) {
        return houseStarService.updateOne(houseStar);
    }

    @DeleteMapping
    public ResponseResult delete(@RequestParam("userId") Integer userId,
                                 @RequestParam("houseId") Long houseId) {
        return houseStarService.delete(userId, houseId);
    }

}
